define(function(require, exports){
	var $		= require("jquery");
	var pubjs	= require('pubjs');
	var popwin	= require('@base/dialog').base;

	var Youku = popwin.extend({
		init:function(config){
			config = pubjs.conf(config, {
				'title': LANG('上传物料'),
				'width': 500,
				//'class': 'P-sweety',
				'id': null,
				'silence': false,
				'view_model': {
					'isAddMode': false
					,'showSelected': false
					,'showSelect': this.showSelect
				}
			});

			this.$data = {};
			this.Super('init', arguments);
		},
		afterBuild:function(){
			this.Super('afterBuild',arguments);
			var el = this.getContainer('body');

			$([
				'<div class="pd15" pub-name="uploader" pub-mod="modules/upload.base"></div>'
			].join('')).appendTo(el);

			var param = $.extend({}, pubjs.config('uploader/youkuCreative'), {
				'target': el,
				'class': 'pd15',
				'subModule': 'modules/upload.sweety',
				'hasProgress': true
			});

			var config = {
				'uploader': param
			};
			this.buildFromTemplate(config);
		},
		afterBuildTemplate: function(){
		},
		getValue: function(){
			return this.$data;
		},
		setParam: function(id){
			this.$id = id;
			return this;
		},
		onFileUploaded: function(ev){
			//todo 上传完成后, 把外面的input 的值设为 url
			//var file = ev.param[0];
			var data = ev.param[1];

			// if(this.$fileId == file.id){
			// 	this.$.assist.update(true);
			// 	this.setData(data);
			// }
			this.fire('youkuUploadSuccess', {id: this.$id, fid: data.fid});
			this.hide();
		}
	});

	exports.youku = Youku;

});